import uvicorn as uvicorn
from loguru import logger

from utils.config import GCF
from app import app
from app.services.yolov8_service import load_yolo_model


def start_process():
    # 日志配置
    if not GCF.log.console_show:
        logger.remove(None)

    if GCF.log.file_show:
        logger.add(
            GCF.log.save_path,
            rotation=GCF.log.rotation,
            compression='zip' if GCF.log.compression else None,
            enqueue=True,
            level=GCF.log.level
        )
    load_yolo_model()


if __name__ == '__main__':
    start_process()
    uvicorn.run(app, host=GCF.server.ip, port=GCF.server.port)
